@extends('layouts.app', ['activePage' => 'course', 'titlePage' => __('课程管理')])

@section('content')
  <div class="content">
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-12">
          <form method="post" action="/courses/{{$course->id}}" autocomplete="off" class="form-horizontal">
            @csrf
            @method('patch')

            <div class="card ">
              <div class="card-header card-header-primary">
                <h4 class="card-title">编辑课程</h4>
                <p class="card-category"></p>
              </div>
              <div class="card-body ">
                <div class="row">
                  <div class="col-md-12 text-right">
                      <a href="/courses" class="btn btn-sm btn-primary">返回课程列表</a>
                  </div>
                </div>
                <form method="POST" action="">
                    <div class="form-group">
                        <label for="title">课程标题</label>
                        <input type="text" class="form-control" name="title" required value="{{$course->title}}">
                        @if ($errors->has('title'))
                          <span id="name-error" class="error text-danger" for="title">至少输入6位字符</span>
                        @endif
                    </div>
                    <div class="form-row">
                      <div class="form-group col-md-6">
                        <label for="title">训练部位</label>
                        <input type="text" class="form-control" name="section" required value="{{$course->section}}">
                        @if ($errors->has('section'))
                          <span id="name-error" class="error text-danger" for="section">至少输入2位字符</span>
                        @endif
                      </div>

                      <div class="form-group col-md-6">
                        <label for="title">课程价格</label>
                        <input step="0.01" type="number" inputmode="tel" class="form-control" name="price" required value="{{$course->price}}">
                        @if ($errors->has('price'))
                          <span id="name-error" class="error text-danger" for="price">请输入大于或等于0的数字</span>
                        @endif
                      </div>
                    </div>

                    <div class="form-group">
                      <label class="label-control">训练时间</label>
                      <input type="datetime" class="form-control" name="train_time" value="{{$course->train_time}}" required />
                      @if ($errors->has('train_time'))
                      <span id="name-error" class="error text-danger" for="train_time">请输入大于明天的日期</span>
                      @endif
                    </div>
                    <div class="form-group">
                        <label for="coach">选择教练</label>
                        <select class="form-control selectpicker" data-style="btn btn-link" name="coach_id" id="coach">
                          @foreach ($course->coach as $coach)
                          <option value={{$coach->id}}>{{$coach->name}}</option>
                          @endforeach
                        </select>
                      </div>
                    <div class="card-footer ml-auto mr-auto">
                      <button type="submit" class="btn btn-primary">提交修改</button>
                    </div>
                  </form>
              </div>

            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
@endsection
